
import React, { useRef, useImperativeHandle, forwardRef } from 'react';
// console.log(file)
const AudioPlayer = forwardRef((props, ref) => {
  const audioRef = useRef(null);

  const playAudio = () => {
    if (audioRef.current) {
        // udioRef.current.src = file;
        audioRef.current.play();
    }
  };

  // 使用 useImperativeHandle 来暴露 playAudio 方法
  useImperativeHandle(ref, () => ({
    playAudio
  }));

  return (
    <audio ref={audioRef}   src='https://admin-web.ime.top/ftp/dowload/dingdingvoice.mp3'  />
  );
});

export default AudioPlayer;